import Vue from 'vue'
import Vuex from 'vuex'
// 引入临时存储文件夹
import storage from '@/utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: storage.get('user'), //保存用户信息
    user_shenhe: storage.get('user_shenhe'), //保存用户审核信息
    token:storage.get('TOKEN'),//存储token字符串
    indexlunbo:storage.get('indexlunbo'),//存储首页信息
    indexdianshi:storage.get('indexdianshi'),//存储首页信息
    indexdongman:storage.get('indexdongman'),//存储首页信息
    indexmovie:storage.get('indexmovie'),//存储首页信息

  },
  getters: {
  },
  mutations: {
     /**保存token */
     saveToken(state, payload) {
      state.token = payload
      storage.save('TOKEN', payload)
    },

    /**保存用户信息 */
    saveUser(state, payload) {
      // 赋值  将user信息赋值给state中的user
      state.user=payload
      storage.save('user', payload)
    },
     /**保存用户审核信息 */
     saveUser_shenhe(state, payload) {
      // 赋值  将user信息赋值给state中的user
      state.user_shenhe=payload
      storage.save('user_shenhe', payload)
    },
    // 保存首页信息
    saveIndexlunbo(state, payload) {
      // 赋值  将user信息赋值给state中的user
      state.indexlunbo=payload
      storage.save('indexlunbo', payload)
    },
    // 保存首页信息
    saveIndexdianshi(state, payload) {
      // 赋值  将user信息赋值给state中的user
      state.indexdianshi=payload
      storage.save('indexdianshi', payload)
    },
    // 保存首页信息
    saveIndexdongman(state, payload) {
      // 赋值  将user信息赋值给state中的user
      state.indexdongman=payload
      storage.save('indexdongman', payload)
    },
    // 保存首页信息
    saveIndexmovie(state, payload) {
      // 赋值  将user信息赋值给state中的user
      state.indexmovie=payload
      storage.save('indexmovie', payload)
    },

  },
  actions: {
  },
  modules: {
  }
})
